{extend name="$_admin_public_base_"/}
{block name="style"}
    <link type="text/css" rel="stylesheet" href="__CSS__/admin.css"/>
{/block}

{block name="main"}
    <div class="row">
    <form id="form_id" method="post" action="{$form_url}" class="form-post form-horizontal">
        <div class="col-md-8 ">
        <div class="box box-info">
            <div class="box-header with-border">
                  <h3 class="box-title">{$meta_title}</h3>
            </div>
             <div class="box-body">
                {notempty name="info.id"}
                    <input type="hidden" name="id" value="{$info.id|default='0'}" />
                {/notempty}
                <div class="form-group w">
                  <!--<label class="col-sm-1 control-label" for="title">标题</label>-->
                  <div class="col-sm-12">
                    <input class="form-control" name="title" value="{$info.title|default=''}" type="text" placeholder="请输入标题">
                  </div>
                  
                </div>
             
                <!--编辑器-->
                <div class="form-group col-sm-12">
                {:widget('common/Editor/wangeditor',
                [
                    [
                        'id'=>'cmscontent',
                        'name'=>'content',
                        'default'=>$info['content'],
                        'width'=>'100%',
                        'height'=>'360px',
                        'config'=>'all'
                    ],
                    [
                        'importWangEditor'     =>1,
                        'open_attachmentModal' =>'multiple'
                    ]
                ])}
                </div>
                <!--编辑器-->
                <div class="page-tabs">
                    <ul class="nav nav-tabs">
                        <li data-tab="tab_seo" class="active"><a href="#tab_seo" data-toggle="tab">SEO信息</a></li>
                        <li data-tab="tab_meta" ><a href="#tab_meta" data-toggle="tab"><i class="fa fa-sticky-note"></i> 自定义栏目</a></li>
                    </ul>
                </div>
                <div class="tab-content box-body">
                    <div id="tab_seo" class='tab-pane active tab_seo'>
                        <p class="help-block">填写seo信息有利于搜索引擎优化</p>
                        <div class="form-group w">
                          <label class="col-sm-2 control-label tl pr-0" for="excerpt">SEO描述:</label>
                          <div class="col-sm-10">
                            <textarea class="form-control" name="excerpt" rows='5'>{$info.excerpt|default=''}</textarea>
                          </div>
                          
                        </div>
                        <div class="form-group w">
                          <label class="col-sm-2 control-label tl" for="seo_keywords">SEO关键字:</label>
                          <div class="col-sm-10">
                            <input class="form-control" name="seo_keywords" value="{$info.seo_keywords|default=''}" type="text">
                            <p class="help-block">多关键词之间用英文逗号隔开</p>
                          </div>
                          
                        </div>
                    </div>

                    <div id="tab_meta" class='tab-pane tab_meta'>
                        <p class="help-block">自定义字段可用来添加在您的主题中可用的<a href="#">额外元数据</a>到您的文章。</p>
                        <div class="repeatable repeatable_courseaudio" >
                            <table class="table table-bordered " >
                                <thead style="background-color: #f0f0f0;">
                                  <tr>
                                    <th >名称</th>
                                    <th >值</th>
                                    <th>操作</th>
                                  </tr>
                                </thead>
                                <tbody data-repeater-list="postmeta">
                                {notempty name="meta_list"}
                                    {volist name="meta_list" id="row"}
                                      <tr data-repeater-item >
                                        <td><input type="text" class="form-control input-sm" name="meta_key" value="{$row.meta_key}" placeholder="元数据key"></td>
                                        <td><textarea class="form-control input-sm" name="meta_value" placeholder="元数据value">{$row.meta_value|default=''}</textarea></td>
                                        <td><label data-repeater-delete class="label label-danger btn-sm" style="cursor: pointer;"><i class="fa fa-trash"></i></label></td>
                                    </tr>
                                    {/volist}
                                {else/}
                                    <tr data-repeater-item >
                                        <td><input type="text" class="form-control input-sm" name="meta_key" value="" placeholder="元数据key"></td>
                                        <td><textarea class="form-control input-sm" name="meta_value" placeholder="元数据value"></textarea></td>
                                        <td><label data-repeater-delete class="label label-danger btn-sm" style="cursor: pointer;"><i class="fa fa-trash"></i></label></td>
                                    </tr>
                                {/notempty}
                                </tbody>
                              </table>
                              <button type="button" data-repeater-create class="btn btn-success btn-sm repeater-add-courseaudio fr mr-10" ><i class="fa fa-plus"></i> 添加</button>
                        </div>
                    </div>
                    
                </div>

            </div>

        </div>
    </div>

    <div class="col-md-4">
        <div class="box box-info">
        <div class="box-header with-border">
              <h3 class="box-title">扩展面板</h3>
        </div>
         <div class="box-body">
            <div class="form-group">
                <label class="control-label col-md-3" style="padding:0;" for="date_d">发布时间:</label>
                <div class="col-md-8"> <input id="date_d" class="form-control form-datetime" type="text" value="{$info.publish_time|default=date('Y-m-d H:i',time())}" name="publish_time" readonly></div>  
            </div>
            <!--<div class="form-group">
                <label class="control-label col-md-4" for="status">审核状态:</label>
                <div class="col-md-8">
                    <select name="status" class="form-control">
                        <option value="1">已发布</option>
                        <option value="3">待审核</option>
                        <option value="0">草稿</option>
                      </select>
                  </div>  
            </div>-->
            <div class="form-group">
                <label class="control-label col-md-3" for="istop">置顶:</label>
                <div class="col-md-8">
                    <input type="checkbox" class="" name="istop" id="istop" value="1" {present name="info.istop" }{eq name="info.istop" value="1" }checked{/eq}{/present}><span class="f12 pl-10 color-6">可在前台置顶显示</span>
                  </div>  
            </div>
            <div class="form-group">
                <label class="control-label col-md-3" for="recommended">推荐:</label>
                <div class="col-md-8">
                    <input type="checkbox" class="" name="recommended" id="recommended" value="1" {present name="info.recommended" }{eq name="info.recommended" value="1" }checked{/eq}{/present}><span class="f12 pl-10 color-6">作为站内推荐</span>
                  </div>  
            </div>
            <div class="form-group">
                <label class="control-label col-md-3" for="status">分类:</label>
                <div class="col-md-8">
                    <select name="category_id" class="form-control">
                    {volist name="post_category" id="val"}
                        <option value="{$key}" {php}if($key==$category_id){echo 'selected';}{/php}>{$val}</option>
                    {/volist}
                    </select>
                  </div>  
            </div>
            <div class="form-group">
                <label class="control-label col-md-3" for="status">标签:</label>
                <div class="col-md-8">
                    <select multiple name="tag_ids" class="form-control">
                    {volist name="post_tags" id="val"}
                        <option value="{$key}" {eq name="key" value="$tag_id"}selected{/eq}>{$val}</option>
                    {/volist}
                    </select>
                  </div>  
            </div>

            <div class="form-group">
                <label class="control-label col-md-3" for="status">排序:</label>
                <div class="col-md-8">
                    <input type="number" class="form-control" name="sort" id="sort" value="0" placeholder="">
                </div>  
            </div>
            
             <div class="form-group">
              <label class="control-label col-md-3" for="title">缩略图:</label>
                <div class="col-md-offset-3">{:widget('common/Upload/picture',[['id'=>'img','class'=>'uploadsingleimg','name'=>'img','value'=>$info['img'],'config'=>'','width'=>false,'height'=>false]])}
                </div>
            </div>
            </div>
        </div><!--box-->
    </div>
    <div class="col-md-12 tc mt-30">
        <div class="box box-solid">

            <div class="box-body">
            {notempty name="info.id"}
                <button class="btn btn-primary ajax-post" data-pjax=false id="login" align="center" type="submit" name="status" value="1" target-form="form-post">更新</button>
            {else/}
                <button class="btn btn-primary ajax-post" id="login" align="center" type="submit" name="status" value="1" target-form="form-post">保存并发布</button>
                <a class="btn btn-default" id="preview" align="center" type="submit" >预览</a>
                <button class="btn btn-default ajax-post" id="save" name="status" value="0" align="center" type="submit" target-form="form-post">保存草稿</button>
            {/notempty}
                <button onclick="javascript:history.back(-1);return false;" class="btn btn-default return">返回</button>
            </div>
        </div>
    </div>
</form>
</div>
{/block}

{block name="script"}
    <link href="__STATIC__/libs/datetimepicker/datetimepicker.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/libs/datetimepicker/datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/libs/jquery-repeater/jquery.repeater.min.js"></script>
    <script>
    $(document).ready(function () {
        $('.form-datetime').datetimepicker({
            language: "zh-CN",
            autoclose: true,
            todayBtn:true,
            format: 'yyyy-mm-dd hh:ii',
        });
        $('.form-date').datetimepicker({
            language: "zh-CN",
            minView: 2,
            autoclose: true,
            format: 'yyyy-mm-dd'
        });
        $('.form-time').datetimepicker({
            language: "zh-CN",
            minView: 0,
            startView:1,
            autoclose: true,
            format: 'hh:ii'
        });
        $('.time').change(function () {
            var fieldName = $(this).attr('data-field-name');
            var dateString = $(this).val();
            var date = new Date(dateString);
            var timestamp = date.getTime();
            $('[name=' + fieldName + ']').val(Math.floor(timestamp / 1000));
        });

        'use strict';
        $('.repeatable_courseaudio').repeater({
            show: function () {
                $(this).slideDown();
            },
            hide: function (deleteElement) {
                if(confirm('您确定要删除吗?')) {
                    $(this).slideUp(deleteElement);
                }
            },
            ready: function (setIndexes) {

            }
        });
    });
    </script>


<script type="text/javascript">
    
        
</script>
{/block}